package com.yanzhenjie.andserver.sample.component;


import com.yanzhenjie.andserver.sample.ServerHttpCode;

/**
 * 作者: Tao
 * 日期: 2023/2/20
 * 时间: 17:09
 * 描述: 自定义exception
 */
public class E7Exception extends RuntimeException {

    private ServerHttpCode code;
    private String title;
    private String detail;
    private String path;
    private int errorCode;

    public E7Exception(ServerHttpCode code, String path) {
        super(code.getDetail());
        this.code = code;
        this.title = code.getTitle();
        this.detail = code.getDetail();
        this.path = path;
        this.errorCode = -1;
    }

    public E7Exception(ServerHttpCode code, String path, int errorCode) {
        super(code.getDetail());
        this.code = code;
        this.title = code.getTitle();
        this.detail = code.getDetail();
        this.path = path;
        this.errorCode = errorCode;
    }

    public E7Exception(ServerHttpCode code, String path, String detail, int errorCode) {
        super(detail);
        this.code = code;
        this.title = code.getTitle();
        this.detail = detail;
        this.path = path;
        this.errorCode = errorCode;
    }

    public ServerHttpCode getCode() {
        return code;
    }

    public void setCode(ServerHttpCode code) {
        this.code = code;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDetail() {
        return detail;
    }

    public void setDetail(String detail) {
        this.detail = detail;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public int getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(int errorCode) {
        this.errorCode = errorCode;
    }

    @Override
    public String toString() {
        return "E7Exception{" +
                "code=" + code +
                ", title='" + title + '\'' +
                ", detail='" + detail + '\'' +
                ", path='" + path + '\'' +
                ", errorCode=" + errorCode +
                '}';
    }

    @Override
    public synchronized Throwable fillInStackTrace() {
        return this;
    }
}
